//
//  BTCvolueCell.m
//  Fireball
//
//  Created by mba on 17/12/27.
//  Copyright © 2017年 俞渊华. All rights reserved.
//

#import "BTCvolueCell.h"

@implementation BTCvolueCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(ValueModel *)model {
    _model = model;
    self.nameLabel.text=[NSString stringWithFormat:@"%d", model.CID ];
    if ([model.Infos count]>0) {
        NSDictionary* a=[model.Infos objectAtIndex:0];
        self.marketValueLabel.text = [NSString stringWithFormat:@"¥%@",[a objectForKey:@"c"]];
        self.currentValueLabel.text = [NSString stringWithFormat:@"¥%@",[a objectForKey:@"l"]];
        NSInteger ratio=(NSInteger)[a objectForKey:@"c"]-(NSInteger)[a objectForKey:@"o"];
        //        self.ValueRatio.titleLabel.text=@"123";
        [self.ValueRatio setTitle:[NSString stringWithFormat:@"%ld%",ratio] forState:nil];
        if (ratio>0) {
            [self.ValueRatio setBackgroundColor:[ToolColor colorWithHexString:@"#3cbc98"]];
        }
        else{
            [self.ValueRatio setBackgroundColor:[ToolColor colorWithHexString:@"#fc5858"]];
        }
    }
}
+ (BTCvolueCell *)cellWithTableView:(UITableView *)tableView {
    static NSString *ID = @"BTCvolueCellID";
    BTCvolueCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[NSBundle mainBundle] loadNibNamed:@"BTCvolueCell" owner:nil options:nil].lastObject;
        cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
        cell.selectedBackgroundView.backgroundColor = [UIColor colorWithRed:105/255.0 green:196/255.0 blue:171/255.0 alpha:0.2];
    }
    return cell;
}
@end
